@import './variables.scss';

// flex布局
@mixin flex($direction: row, $justify: flex-start, $align: stretch, $wrap: nowrap) {
  display: flex;
  flex-direction: $direction;
  justify-content: $justify;
  align-items: $align;
  flex-wrap: $wrap;
}

// 文本溢出省略
@mixin text-ellipsis($lines: 1) {
  @if $lines == 1 {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  } @else {
    display: -webkit-box;
    -webkit-line-clamp: $lines;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
}

// 滚动条样式
@mixin scrollbar {
  &::-webkit-scrollbar {
    width: 6px;
    height: 6px;
  }

  &::-webkit-scrollbar-thumb {
    border-radius: 3px;
    background-color: rgba(0, 0, 0, 0.2);
  }

  &::-webkit-scrollbar-track {
    border-radius: 3px;
    background-color: rgba(0, 0, 0, 0.1);
  }
}

// 清除浮动
@mixin clearfix {
  &::after {
    content: '';
    display: table;
    clear: both;
  }
}

// 多行文本溢出
@mixin multi-line-ellipsis($line: 2) {
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: $line;
}

// 绝对定位居中
@mixin absolute-center($position: both) {
  position: absolute;
  
  @if $position == both {
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
  } @else if $position == horizontal {
    left: 50%;
    transform: translateX(-50%);
  } @else if $position == vertical {
    top: 50%;
    transform: translateY(-50%);
  }
}

// 响应式断点
@mixin respond-to($breakpoint) {
  @if $breakpoint == "small" {
    @media (max-width: 767px) { @content; }
  } @else if $breakpoint == "medium" {
    @media (min-width: 768px) and (max-width: 1024px) { @content; }
  } @else if $breakpoint == "large" {
    @media (min-width: 1025px) { @content; }
  }
}

// 渐变背景
@mixin gradient($start-color, $end-color, $direction: to right) {
  background: linear-gradient($direction, $start-color, $end-color);
}

// 阴影效果
@mixin box-shadow($level: 1) {
  @if $level == 1 {
    box-shadow: $box-shadow-light;
  } @else if $level == 2 {
    box-shadow: $box-shadow;
  } @else if $level == 3 {
    box-shadow: $box-shadow-dark;
  }
}

// 禁用文本选择
@mixin no-select {
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
} 